﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Transactions;
using EnCor.Config;
using System.ComponentModel;
using EnCor.Security;

namespace EnCor.Security
{
    public abstract class AuthenticationProvider : IAuthenticationProvider, ISupportCredentialType
    {
        private string _Tag = string.Empty;

        private string _Mapper;

        protected AuthenticationProvider()
        {
            
        }

        #region ISupportCredentialType Members

        public string Tag 
        {
            get { return _Tag; }
            internal set { _Tag = value; }
        }

        public bool SupportCredentialType(string credentialType)
        {
            return string.Compare(CredentialType, credentialType, true) == 0;
        }

        #endregion

        /// <summary>
        /// Authenticate User Credential
        /// </summary>
        /// <param name="credential">Credential</param>
        /// <returns>Return authenticated identity, null for can't authenticate</returns>
        public abstract UserIdentity Authenticate(Credential credential);

        /// <summary>
        /// The CredentialType AuthenticationProvider supported
        /// </summary>
        public abstract string CredentialType { get; }


        #region IAuthenticationProvider Members


        public string Mapper
        {
            get { return _Mapper; }
            set { _Mapper = value; }
        }

        #endregion
    }
}
